<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
  <meta name="screen-orientation" content="portrait" />
  <meta name="apple-mobile-web-app-capable" content="no">
  <meta name="format-detection" content="telephone=no">
  <meta name="full-screen" content="yes">
  <meta name="x5-fullscreen" content="true">
  <!-- <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" /> -->
  <!-- 缓存清除 -->
  <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  <meta http-equiv="Pragma" content="no-cache" />
  <meta http-equiv="Expires" content="0" />
  <title>加载中...</title>
  <script src="/config.js"></script>
  <style>
    .fphd_platform_loading {
      display: inline-block;
      position: relative;
      color: #c8c9cc;
      font-size: 0;
      vertical-align: middle;
    }

    .fphd_platform_loading__spinner--spinner {
      animation-timing-function: steps(12);
    }

    .fphd_platform_loading__spinner {
      position: relative;
      display: inline-block;
      width: 40px;
      max-width: 100%;
      height: 40px;
      max-height: 100%;
      vertical-align: middle;
      -webkit-animation: fphd_platform_rotate 0.8s linear infinite;
      animation: fphd_platform_rotate 0.8s linear infinite;
    }

    .fphd_platform_loading {
      font-size: 0;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(1) {
      transform: rotate(30deg);
      opacity: 1;
    }

    .fphd_platform_loading__spinner--spinner i {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }

    .fphd_platform_loading__spinner--spinner i::before {
      display: block;
      width: 2px;
      height: 25%;
      margin: 0 auto;
      background-color: currentColor;
      border-radius: 40%;
      content: ' ';
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(1) {
      -webkit-transform: rotate(30deg);
      transform: rotate(30deg);
      opacity: 1;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(2) {
      -webkit-transform: rotate(60deg);
      transform: rotate(60deg);
      opacity: 0.9375;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(3) {
      -webkit-transform: rotate(90deg);
      transform: rotate(90deg);
      opacity: 0.875;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(4) {
      -webkit-transform: rotate(120deg);
      transform: rotate(120deg);
      opacity: 0.8125;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(5) {
      -webkit-transform: rotate(150deg);
      transform: rotate(150deg);
      opacity: 0.75;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(6) {
      -webkit-transform: rotate(180deg);
      transform: rotate(180deg);
      opacity: 0.6875;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(7) {
      -webkit-transform: rotate(210deg);
      transform: rotate(210deg);
      opacity: 0.625;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(8) {
      -webkit-transform: rotate(240deg);
      transform: rotate(240deg);
      opacity: 0.5625;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(9) {
      -webkit-transform: rotate(270deg);
      transform: rotate(270deg);
      opacity: 0.5;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(10) {
      -webkit-transform: rotate(300deg);
      transform: rotate(300deg);
      opacity: 0.4375;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(11) {
      -webkit-transform: rotate(330deg);
      transform: rotate(330deg);
      opacity: 0.375;
    }

    .fphd_platform_loading__spinner--spinner i:nth-of-type(12) {
      -webkit-transform: rotate(360deg);
      transform: rotate(360deg);
      opacity: 0.3125;
    }

    @-webkit-keyframes fphd_platform_rotate {
      from {
        -webkit-transform: rotate(0deg);
        transform: rotate(0deg);
      }

      to {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
      }
    }

    @keyframes fphd_platform_rotate {
      from {
        -webkit-transform: rotate(0deg);
        transform: rotate(0deg);
      }

      to {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
      }
    }

    .fphd_platform_loading__spinner--spinner {
      -webkit-animation-timing-function: steps(12);
      animation-timing-function: steps(12);
    }

    #fphd_platform_index_loading {
      position: fixed;
      top: 45%;
      left: 25%;
      width: 50%;
      text-align: center;
    }
    body { /* IOS禁止微信调整字体大小 */
      -webkit-text-size-adjust: 100% !important;
      text-size-adjust: 100% !important;
      -moz-text-size-adjust: 100% !important;
    }
  </style>
  <script type="text/javascript" src="https://alpha-uc.fpwan.com/misc/js/vconsole.min.js"></script>
  <script>
    // 如果是微信环境，清除登录信息，每次都让用户登录
    let ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
      localStorage.clear()
    }

    // 加载各个项目的版本库文件
    // if (location.host.indexOf('alpha') >= 0 || location.host.indexOf('beta') >= 0) {
    //   var vConsole = new VConsole();
    // }

    var loadedJsFiles = {};

    function httpDoGet(obj) {

      var url = obj.url;
      var onSuccess = obj.onSuccess;
      if (!url) {
        console.error("no url");
        return;
      }
      if (!onSuccess) {
        console.error("no onSuccess");
        return;
      }

      var xhr = new XMLHttpRequest();
      var urlArr = url.split("?");
      if (obj.requestMethod == 'GET') {
        if (urlArr[1]) {
          xhr.open("GET", urlArr[0], true);
          xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
          xhr.send(urlArr[1]);
        } else {
          xhr.open("GET", url, true);
          xhr.send();
        }
      } else {
        if (urlArr[1]) {
          xhr.open("POST", urlArr[0], true);
          xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
          xhr.send(urlArr[1]);
        } else {
          xhr.open("POST", url, true);
          xhr.send();
        }
      }

      xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
          if (xhr.status >= 400 || xhr.status == 0) {
            console.error("404:" + url);
          }
          else {
            var data = {"response": xhr.responseText};
            onSuccess(data);
          }
        }
      };
    }

    /**
     * 异步加载js文件
     *
     * @param scripts js文件数组
     * @param callback 并行异步加载完成后的回调
     */
    function loadJs(scripts, callback) {
      console.log("loadJs ===============")
      console.log(scripts)
      if (typeof (scripts) != "object") var scripts = [scripts];
      var haveLoaded = true;
      for (var i = 0; i < scripts.length; i++) {
        if (!loadedJsFiles[scripts[i]]) {
          haveLoaded = false;
          loadedJsFiles[scripts[i]] = 1;
        }
      }

      if (haveLoaded) {
        callback();
        return;
      }

      var HEAD = document.getElementsByTagName("head").item(0) || document.documentElement;
      var s = new Array(),
      last = scripts.length - 1,
      recursiveLoad = function (i) {
        s[i] = document.createElement("script");
        s[i].setAttribute("type", "text/javascript");
        s[i].setAttribute("defer", "defer");
        s[i].onload = s[i].onreadystatechange = function () { //Attach handlers for all browsers
          if (!0 || this.readyState == "loaded" || this.readyState == "complete") {
            this.onload = this.onreadystatechange = null;
            this.parentNode.removeChild(this);
            if (i != last) recursiveLoad(i + 1);
            else callback();
          }
        };
        s[i].setAttribute("src", scripts[i]);
        HEAD.appendChild(s[i]);
      };

      recursiveLoad(0);
    }

    // 获取 js sdk 文件路径
    var nowDomain = '';
    var sdkDomain = '';
    var apiServerUrl = '';
    var host = location.host.split("-");
    if (host.length > 1) {
      if (host[0] == 'alpha' || host[0] == 'beta') {
        nowDomain = location.protocol + '//' + host[0] + '-game-hall.fpwan.com';
        sdkDomain = location.protocol + '//' + host[0] + '-game-hall.fpwan.com';
        apiServerUrl = location.protocol + '//' + host[0] + '-uc.fpwan.com';
      
      } else {
        nowDomain = location.protocol + '//' + 'game-hall.fpwan.com';
        apiServerUrl = location.protocol + '//' + 'uc.fpwan.com';
        
       
      }

    } else {
      if (host[0].indexOf('localhost') != -1) {
        nowDomain = location.protocol + '//' + 'alpha-game-hall.fpwan.com';
        sdkDomain = location.protocol + '//' + 'alpha-game-hall.fpwan.com';
        apiServerUrl = location.protocol + '//' + 'alpha-uc.fpwan.com';
      } else {
        nowDomain = location.protocol + '//' + 'game-hall.fpwan.com';
        sdkDomain = location.protocol + '//' + 'game-hall.fpwan.com';
        apiServerUrl = location.protocol + '//' + 'uc.fpwan.com';
      
      }
    }
    apiServerUrl = JONO_HOST
    var queryStr = location.search.slice(1).split("&");
    var queryData = {};
    queryStr.forEach((n, i) => {
      var item = n.split('=');
      queryData[item[0]] = item[1];
    });

    var postUrl = apiServerUrl + "/appVersion/getJSVersion?channelId=" + queryData.channelId;
    httpDoGet({
      url: postUrl,
      onSuccess: function (data) {
        var dataObj = eval("(" + data.response + ")");//转换为json对象
        if (dataObj.code === 0) {
          init(dataObj.data.version);
          // var timestamp = new Date().getTime();
          // init(timestamp);
        } else {
          var timestamp = new Date().getTime();
          init(timestamp);
        }
      },
      onFail: function () {
        var timestamp = new Date().getTime();
        init(timestamp);
      }
    });

    console.log("加载 fphdsdk.js 开始时间：" + new Date().getTime());

    function init(version) {
      console.log("version ========== A")
      console.log(version)
      var gaodeKey = 'd63c9bad74fafd6e29e4765bc7afac62';
      var jsFiles = [
        '/plupload-2.1.2/moxie.min.js',
        '/plupload-2.1.2/plupload.min.js',
        'https://alpha-admin.fpwan.com/manage/js/vendor/jquery.js',
        '/hall/common/js/loghub-tracking.js',
        'https://webapi.amap.com/maps?v=1.4.15&key=' + gaodeKey,
        'https://webapi.amap.com/ui/1.0/main.js?v=1.0.11',
        'https://a.amap.com/jsapi_demos/static/remogeo/remogeo.js',
        "/hall/common/js/jquery.qrcode.min.js",
        /* sdkDomain + '/sdk/fphdsdk.js?v=' + version,
        sdkDomain + '/sdk/fphdtasksdk.js?v=' + version, */
        '/sdk/fphdsdk.js?v=' + version,
        '/sdk/fphdtasksdk.js?v=' + version,

        '/gamehall/version.js?v=' + version 

        // nowDomain + '/gamehall/version.js?v=' + version
      ];
      // 加载sdk文件
      loadJs(jsFiles, function () {
        console.log("加载 fphdsdk.js 结束时间：" + new Date().getTime());
        loadFphdPlatFormVersionFileList();
      });
      console.log(version,6666666666)
    }

    function loadFphdPlatFormVersionFileList() {
      console.log("异步加载 version.js内 runtime、vendor、app 开始时间：" + new Date().getTime());
      var SystemType = FPHDSdk.getSystemType()
      var BrowserType = FPHDSdk.getBrowserType()
      if (
        SystemType == 'ios' || SystemType == "miniprogram" || SystemType == 'web'
        || BrowserType == 'any' || BrowserType == 'fphdOldApp' || BrowserType == 'fphdNewApp' || BrowserType == 'fphdApp' || BrowserType == 'chrome'
      ) {
        loadBenDiWan()
      }else{
        if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") {
          handleFontSize();
        } else {
          if (document.addEventListener) {
            document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
          } else if (document.attachEvent) {
            document.attachEvent("WeixinJSBridgeReady", handleFontSize);
            document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
          }
        }
        function handleFontSize() {
          // 设置网页字体为默认大小
          WeixinJSBridge.invoke('setFontSizeCallback', {
            'fontSize': 0
          });
          // 重写设置网页字体大小的事件
          WeixinJSBridge.on('menu:setfont', function () {
            WeixinJSBridge.invoke('setFontSizeCallback', {
              'fontSize': 0
            });
          });
          loadBenDiWan();
        }
      }
    }

    function loadBenDiWan() {
      // 加载各个项目的版本库文件
      if (location.host.indexOf('alpha') >= 0) {
        FPHDSdk.loadJs(fphdPlatFormFileListVersion, function () {
          console.log("异步加载 version.js内 runtime、vendor、app 结束时间：" + new Date().getTime());

          document.getElementById("fphd_platform_index_loading").innerHTML = '';
        });
      } else if (location.host.indexOf('beta') >= 0) {
        FPHDSdk.loadJs(fphdPlatFormFileListVersion, function () {
          console.log("异步加载 version.js内 runtime、vendor、app 结束时间：" + new Date().getTime());

          document.getElementById("fphd_platform_index_loading").innerHTML = '';
        });
      } else {
        FPHDSdk.loadJs(fphdPlatFormFileListVersion, function () {
          console.log("异步加载 version.js内 runtime、vendor、app 结束时间：" + new Date().getTime());

          document.getElementById("fphd_platform_index_loading").innerHTML = '';
        });
      }
    }
  </script>
</head>

<body>
  <div id="app">
  </div>
  <div id="fphd_platform_index_loading">
    <div class="fphd_platform_loading fphd_platform_loading--spinner">
      <span class="fphd_platform_loading__spinner fphd_platform_loading__spinner--spinner"
        style="color: rgb(249, 102, 52);">
        <i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i>
      </span>
    </div>
  </div>
 </body>
</html>
